<template>
	<view>
		<view class="item">

			<u-icon name="order" color="#1573FF" label="审核意见" label-color="#333333"
				:customStyle="{'line-height': '80rpx','display': 'block','padding-left':'20rpx',}"></u-icon>

			<u-line color="#efefef" :customStyle="{'margin-bottom': '10rpx','display': 'block',}"></u-line>

			<view style="margin: 20rpx;">
				<u-textarea v-model="remark" placeholder="请输入审核意见" height="150"></u-textarea>
			</view>

		</view>


		<view class="button-container">
			<button class="btn-item" @click="commit">{{1==type?'确认拒绝':
			2==type?'确认驳回':
			3==type?'确认通过':
			4==type||7==type?'审核通过':
			5==type?'确认撤回':
			6==type?'确认删除':
			''}}</button>

		</view>
	</view>
</template>

<script>
	import {
		k_api_orderDel,
		k_api_orderRecall,
		k_api_orderListapproven,
		k_api_orderRefuset,
		k_api_orderrReject,
		k_api_orderaApprove
	} from '@/common/http.api.js'

	export default {
		data() {
			return {
				type: 0,
				orderId: '',
				exam_url: '',
				remark:'',
				addbean: {
				}

			}
		},
		methods: {
			commit() {

				let that = this;

				if (uni.$u.test.isEmpty(this.remark)) {
					this.$u.toast('请输入审核意见')
					return
				}

				uni.showModal({
					content: '确定提交吗?',
					success(res) {
						if (res.confirm) {
              uni.showLoading()

							if (4 == that.type || 7 == that.type) {
								that.addbean.auditMark = that.remark

								that.$u.api.examorderjson(that.exam_url, that.addbean)
									.then(res => {
                    uni.hideLoading()
										that.$u.toast('提交成功')
										uni.$emit('exam-finish', true)
										uni.$emit('refreshOrder', true)
                    uni.$emit('approval', true)
										setTimeout(() => {
											uni.navigateBack()
										}, 500)
										
									}).catch(e=>{
                    uni.hideLoading()
                  })
							} else {
								that.$u.api.examorderform(that.exam_url, {
									orderId: that.orderId,
									auditMark: that.remark
								}).then(res => {
                  uni.hideLoading()
									that.$u.toast('提交成功')
									uni.$emit('exam-finish', true)
									uni.$emit('refreshOrder', true)
                  uni.$emit('approval', true)
									setTimeout(() => {
										uni.navigateBack()
									}, 500)
								}).catch(e=>{
                  uni.hideLoading()
                })
							}

						}
					}
				})
			}
		},
		onLoad(op) {
			//1拒绝  2驳回   3列表直接通过    4编辑后通过  5撤回   6删除   7审核页面直接通过
			
			console.log('收到的examorder==>', getApp().globalData.exam_order);

			this.orderId = op.orderId;
			this.type = op.type;
			this.addbean = uni.$u.test.isEmpty(getApp().globalData.exam_order)?{}:getApp().globalData.exam_order;

			getApp().globalData.exam_order = null;
			
			


			if (1 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认拒绝'
				})
				this.exam_url = k_api_orderRefuset;
			} else if (2 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认驳回'
				})
				this.exam_url = k_api_orderrReject;
			} else if (3 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认通过'
				})
				this.exam_url = k_api_orderListapproven;
			} else if (4 == this.type || 7 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认通过'
				})
				this.exam_url = k_api_orderaApprove;
			} else if (5 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认撤回'
				})
				this.exam_url = k_api_orderRecall;
			} else if (6 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认删除'
				})
				this.exam_url = k_api_orderDel;
			}

		}
	}
</script>

<style lang="scss" scoped>
	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 98%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
